﻿using System.Collections.Generic;
using System.Web.Services;
using MTC.Common.DTO;

namespace MTC.WebServices
{
    /// <summary>
    /// Summary description for Driver
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Driver : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
//        public List<Common.DTO.Driver> GetDrivers(Session session)
        public List<Common.DTO.Driver> GetDrivers()
        {
            //if (!Business.Security.Session.IsValid(session))
            //{
            //    return null;
            //}
            return Business.Driver.Driver.GetDrivers();
        }

        [WebMethod]
        public int AddDriver(Session session, Common.DTO.Driver driver)
        {
            if (!Business.Security.Session.IsValid(session))
                return 0;

            return Business.Driver.Driver.AddDriver(driver);
        }

        [WebMethod]
        public bool UpdateDriver(Session session, Common.DTO.Driver driver)
        {
            if (!Business.Security.Session.IsValid(session))
                return false;

            return Business.Driver.Driver.UpdateDriver(driver);

        }

        [WebMethod]
        public bool DeleteDriver(Session session, int DriverId)
        {
            if (!Business.Security.Session.IsValid(session))
                return false;

            return Business.Driver.Driver.DeleteDriver(DriverId);
        }

    }
}
